import 'package:finance_app/src/entities/plans_item_entity.dart';

plansItemEntityFromJson(PlansItemEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['name_text'] != null) {
		data.nameText = json['name_text'].toString();
	}
	if (json['price'] != null) {
		data.price = json['price'].toString();
	}
	if (json['upgrade_price'] != null) {
		data.upgradePrice = json['upgrade_price'].toString();
	}
	if (json['price_text'] != null) {
		data.priceText = json['price_text'].toString();
	}
	if (json['description'] != null) {
		data.description = json['description'].toString();
	}
	if (json['transaction_limit'] != null) {
		data.transactionLimit = json['transaction_limit'] is String
				? int.tryParse(json['transaction_limit'])
				: json['transaction_limit'].toInt();
	}
	if (json['transaction_count'] != null) {
		data.transactionCount = json['transaction_count'] is String
				? int.tryParse(json['transaction_count'])
				: json['transaction_count'].toInt();
	}
	if (json['is_current_subscribed'] != null) {
		data.isCurrentSubscribed = json['is_current_subscribed'] is String
				? int.tryParse(json['is_current_subscribed'])
				: json['is_current_subscribed'].toInt();
	}
	if (json['issuesDate'] != null) {
		data.issuesDate = json['issuesDate'].toString();
	}
	if (json['dueAt'] != null) {
		data.dueAt = json['dueAt'].toString();
	}
	return data;
}

Map<String, dynamic> plansItemEntityToJson(PlansItemEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['type'] = entity.type;
	data['name'] = entity.name;
	data['name_text'] = entity.nameText;
	data['price'] = entity.price;
	data['upgrade_price'] = entity.upgradePrice;
	data['price_text'] = entity.priceText;
	data['description'] = entity.description;
	data['transaction_limit'] = entity.transactionLimit;
	data['transaction_count'] = entity.transactionCount;
	data['is_current_subscribed'] = entity.isCurrentSubscribed;
	data['issuesDate'] = entity.issuesDate;
	data['dueAt'] = entity.dueAt;
	return data;
}